<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <h1>Promise</h1>

    <script>
      // pending  准备阶段
      // 准备阶段结束 通过两个方法来通知
      // resole 和 reject  通过 这两个方法来通知 然后 改变 这个promise的状态
      // resolve 成功状态
      // reject 失败 状态

      let p1 = new Promise((resolve, reject) => {
        resolve('成功')
      })

      new Promise((resolve, reject) => {
        reject('失败')
      }).then(
        (msg) => {
          console.log(msg)
        },
        (error) => {
          console.log(error, 'err')
        }
      )
    </script>
  </body>
</html>
